package com.wkh.project.constant;

/**
 * @author wangkehua
 * redis常量
 */
public interface RedisConstant {
    /**
     * 用户签到记录key前缀
     */
    String USER_SIGN_IN_REDIS_KEY_PREFIX = "user:signins";

    String QUESTION_BANK_DETAIL="question_bank_detail_";
    String QUESTION_DETAIL="question_detail_";

    /**
     * 获取用户签到记录key
     * @param year 年份
     * @param userId 用户id
     * @return 拼接好的redis key
     */
    static String getUserSignInRedisKey(int year, String userId){
        return String.format("%s:%s:%s",USER_SIGN_IN_REDIS_KEY_PREFIX,year,userId);
    }

    /**
     * 获取热点key
     * @param id 题库id
     * @return QuestionBank questionBank = questionBankService.getById(id);
     */
    static String getBankDetailKey(Long id){
        return String.format("%s%s",QUESTION_BANK_DETAIL,id);
    }

    /**
     * 获取热点key
     * @param id 题目id
     * @return Question question = questionService.getById(id);
     */
    static String getQuestionDetail(Long id){
        return String.format("%s%s",QUESTION_DETAIL,id);
    }
}
